package com.fromfuture.xuhuidoc.cordova.untils;

import android.graphics.Bitmap;
import android.os.AsyncTask;

import com.fromfuture.xuhuidoc.cordova.callback.OnImageSuccessListener;


/**
 * Created by hp on 2017/7/20.
 */

public class ImageTask  extends AsyncTask<String,Void,Bitmap> {

    private OnImageSuccessListener listener;
    public ImageTask(OnImageSuccessListener listener) {
        super();
        this.listener = listener;
    }
    @Override
    protected Bitmap doInBackground(String... params) {
        //项目里包含不可饶恕的重大安全隐患：病人聊天端的图片url地址里包含账号和密码。
        String url=params[0];
        Bitmap bitmap= MyHttpUtils.getBitmapFromUrl(url);
        return bitmap;
    }

    @Override
    protected void onPostExecute(Bitmap bitmap) {
        super.onPostExecute(bitmap);
        try{
            listener.onImageSuccess(bitmap);
        }catch (Exception e){

        }

    }

}
